** Strategic Retirement in Comparative Perspective: Supreme Court Justices in Presidential Regimes
*   Aníbal Pérez-Liñán, University of Pittsburgh (asp27@pitt.edu)
*   Ignacio Arana Araya, Pontificia Universidad Católica de Chile (iga3@pitt.edu)
*   5/13/2017
** Journal of Law and Courts, vol. 5, no. 2 (2017) 

* Careers v 11		   
use "strategic_retirement.dta",clear
xtset jcode year


*** Table 3
* Model 3.1 - US
xtlogit voluntary_exit copartisan                                             ///
                       health_age co_age                                     /// /* H1 */
					   polity2                                               /// 
					   pre_politician                                        /// 
					   distcourt distcourt2                                  /// 
					   retirement_benefits second_term career_judge post_politician	if cowcode == 2	
est store M31
* Effects for Table 4 (row 1)
lincom copartisan+co_age*60, or l(99)
lincom copartisan+co_age*80, or l(99)

* Model 3.2 - Argentina
xtlogit voluntary_exit copartisan                                            ///
                       health_age co_age                            /// /* H1 */
					   polity2                                               /// 
					   pre_politician                                        /// 
					   distcourt distcourt2                                  /// 
					   retirement_benefits second_term career_judge post_politician	if cowcode == 160
est store M32
* Effects for Table 4 (row 2)
lincom copartisan+co_age*60, or l(99)
lincom copartisan+co_age*80, or l(99)

* Model 3.3 - Brazil
xtlogit voluntary_exit copartisan                                            ///
                       health_age co_age                            /// /* H1 */
					   polity2                                               /// 
					   pre_politician                                        /// 
					   distcourt distcourt2                                  /// 
					   retirement_benefits second_term career_judge post_politician	if cowcode == 140
est store M33
* Effects for Table 4 (row 3)
lincom copartisan+co_age*60, or l(99)
lincom copartisan+co_age*80, or l(99)

* Model 3.4 - Chile 
xtlogit voluntary_exit copartisan                                            ///
                       health_age co_age                            /// /* H1 */
					   polity2                                               /// 
					   pre_politician                                        /// 
					   distcourt distcourt2                                  /// 
					   retirement_benefits second_term career_judge post_politician	if cowcode == 155
est store M34
* Effects for Table 4 (row 4)
lincom copartisan+co_age*60, or l(99)
lincom copartisan+co_age*80, or l(99)


* Model 3.5 - Mexico
xtlogit voluntary_exit copartisan                                            ///
                       health_age co_age                            /// /* H1 */
					   polity2                                               /// 
					   pre_politician                                        /// 
					   distcourt distcourt2                                  /// 
					   retirement_benefits second_term career_judge post_politician	if cowcode == 70	
est store M35
* Effects for Table 4 (row 5)
lincom copartisan+co_age*60, or l(99)
lincom copartisan+co_age*80, or l(99)


* Model 3.6 - Panama
xtlogit voluntary_exit copartisan                                            ///
                       health_age co_age                            /// /* H1 */
					   polity2                                               /// 
					   pre_politician                                        /// 
					   distcourt distcourt2                                  /// 
					   retirement_benefits second_term career_judge post_politician	if cowcode == 95
est store M36
* Effects for Table 4 (row 6)
lincom copartisan+co_age*60, or l(99)
lincom copartisan+co_age*80, or l(99)


esttab M31 M32 M33 M34 M35 M36 using "Table3.rtf", cell(b(star fmt (%9.2f)) se(par))  ///
       stats(N chi2 ll, fmt(%9.0g %9.2f %9.2f) labels("N" "Chi^2" "Log-L") )starlevels(+ 0.1 * 0.05 ** 0.01) ///
       legend label varlabels(_cons Constant)title("Table 3. Tests of H1, by Country") mtitles replace

	   

*** Table 5
* Model 5.1
xtlogit voluntary_exit copartisan                                            ///
                       health_age                                            /// 
					   polity2                                               ///
					   pre_politician                                        /// 
					   distcourt distcourt2                                  /// 
					   retirement_benefits second_term career_judge post_politician		
est store M51

* Model 5.2
xtlogit voluntary_exit copartisan                                            ///
                       health_age co_age                            /// /* H1 */
					   polity2    co_polity                         /// /* H2 */
					   pre_politician                                        /// 
					   distcourt distcourt2                                  /// 
					   retirement_benefits second_term career_judge post_politician		
est store M52

* Model 5.3
xtlogit voluntary_exit copartisan                                            ///
                       health_age co_age                            /// /* H1 */
					   polity2    co_polity                         /// /* H2 */
					   pre_politician co_politician                 /// /* H3 */
					   distcourt distcourt2                         /// /* H4 */
					   co_dist co_dist2                                     ///
					   retirement_benefits second_term career_judge post_politician		
est store M53

* Model 5.4
xtlogit voluntary_exit copartisan                                            ///
                       health_age co_age                            /// /* H1 */
					   polity2    co_polity                         /// /* H2 */
					   age_polity co_age_polity                     /// 
					   pre_politician co_politician                 /// /* H3 */
					   distcourt distcourt2                         /// /* H4 */
					   co_dist co_dist2                                     ///
					   retirement_benefits second_term career_judge post_politician	
est store M54

* Odds ratio under favorable conditions of age and other moderators (footnote 16)
lincom copartisan+co_age*80+co_polity*10+co_age_polity*800+co_politician*1+co_dist*.5+co_dist2*.25, or l(99)

esttab M51 M52 M53 M54 using "Table5.rtf", cell(b(star fmt (%9.2f)) se(par)) ///
       stats(N chi2 ll, fmt(%9.0g %9.2f %9.2f) labels("N" "Chi^2" "Log-L") )starlevels(+ 0.1 * 0.05 ** 0.01) ///
       legend label varlabels(_cons Constant)title("Table 5. Models of Voluntary Retirement, 1900-2004") mtitles replace
					   
					   
*** Figure 2 (Model 5.4)
xtlogit voluntary_exit i.copartisan ///
                       c.health_age i.copartisan#c.health_age         /// /* H1 */
					   c.polity2    i.copartisan#c.polity2            /// /* H2 */
					   c.health_age#c.polity2 i.copartisan#c.health_age#c.polity2 /// 
					   i.pre_politician i.copartisan#i.pre_politician /// /* H3 */
					   c.distcourt c.distcourt#c.distcourt            /// /* H4 */
					   i.copartisan#c.distcourt i.copartisan#c.distcourt#c.distcourt ///
					   retirement_benefits second_term career_judge post_politician			   

* H1 Age
margins copartisan, at (health_age = (30 (10) 90)) predict(pu0)
marginsplot, name("g01", replace) recast(line) recastci(rarea) ytitle("") title(2.1 - H1: Age) legend(region(lcolor(none)))
graph save g01 "g01.gph", replace

* H2 Party Competition
margins copartisan, at (health_age = (30 (10) 90) polity2 = -9) predict(pu0)
marginsplot, name("g02", replace) recast(line) recastci(rarea) ytitle("") title(2.2 - H2: If Dictatorship [-9]) legend(region(lcolor(none)))
graph save g02 "g02.gph", replace

margins copartisan, at (health_age = (30 (10) 90) polity2 = 9) predict(pu0)
marginsplot, name("g03", replace) recast(line) recastci(rarea) ytitle("") title(2.3 - H2: If Democracy [+9]) legend(region(lcolor(none)))
graph save g03 "g03.gph", replace

* H3 Party ID
margins copartisan, at (health_age = (30 (10) 90) pre_politician = 0) predict(pu0)
marginsplot, name("g04", replace) recast(line) recastci(rarea) ytitle("") title(2.4 - H3: If Not Politician) legend(region(lcolor(none)))
graph save g04 "g04.gph", replace

margins copartisan, at (health_age = (30 (10) 90) pre_politician = 1) predict(pu0)
marginsplot, name("g05", replace) recast(line) recastci(rarea) ytitle("") title(2.5 - H3: If Prior Politician) legend(region(lcolor(none)))
graph save g05 "g05.gph", replace

* H4 Divided Court
margins copartisan, at (distcourt = (0 (.25) 1) health_age = 65) predict(pu0)
marginsplot, name("g06", replace) recast(line) recastci(rarea) ytitle("") title(2.6 - H4: Court Balance) xline(0.5) legend(region(lcolor(none)))
graph save g06 "g06.gph", replace

graph combine g01.gph g02.gph g03.gph g04.gph g05.gph g06.gph, ycommon


*** Table 2 (Descriptives)
* Column 1 - United States
sum voluntary_exit copartisan health_age polity2 pre_politician distcourt ///
    retirement_benefits second_term career_judge post_politician if cowcode == 2
* Column 2 - Latin America
sum voluntary_exit copartisan health_age polity2 pre_politician distcourt ///
    retirement_benefits second_term career_judge post_politician if cowcode != 2
* Column 3 - All in sample
sum voluntary_exit copartisan health_age polity2 pre_politician distcourt ///
    retirement_benefits second_term career_judge post_politician if e(sample)


*** Robustness Tests (Not included in the paper) ***

*** Models including Linzer & Staton's Index of Judicial Independence
* Model 6.1
xtlogit voluntary_exit copartisan                                            ///
                       health_age                                            /// 
					   polity2                                               ///
					   pre_politician                                        /// 
					   distcourt distcourt2                                  /// 
					   retirement_benefits second_term career_judge post_politician lji		
est store M61

* Model 6.2
xtlogit voluntary_exit copartisan                                            ///
                       health_age co_age                            /// /* H1 */
					   polity2    co_polity                         /// /* H2 */
					   pre_politician                                        /// 
					   distcourt distcourt2                                  /// 
					   retirement_benefits second_term career_judge post_politician lji
est store M62

* Model 6.3
xtlogit voluntary_exit copartisan                                            ///
                       health_age co_age                            /// /* H1 */
					   polity2    co_polity                         /// /* H2 */
					   pre_politician co_politician                 /// /* H3 */
					   distcourt distcourt2                         /// /* H4 */
					   co_dist co_dist2                                     ///
					   retirement_benefits second_term career_judge post_politician lji		
est store M63

* Model 6.4
xtlogit voluntary_exit copartisan                                            ///
                       health_age co_age                            /// /* H1 */
					   polity2    co_polity                         /// /* H2 */
					   age_polity co_age_polity               /// /* Optional */
					   pre_politician co_politician                 /// /* H3 */
					   distcourt distcourt2                         /// /* H4 */
					   co_dist co_dist2                                     ///
					   retirement_benefits second_term career_judge post_politician lji	
est store M64

esttab M61 M62 M63 M64 using "Table6.rtf", cell(b(star fmt (%9.2f)) se(par)) ///
       stats(N chi2 ll, fmt(%9.0g %9.2f %9.2f) labels("N" "Chi^2" "Log-L") )starlevels(+ 0.1 * 0.05 ** 0.01) ///
       legend label varlabels(_cons Constant)title("Table 6. Models of Voluntary Retirement, 1945-2004") mtitles replace
					   

*** Models for the sub-sample of Democracies
* Model 7.1
xtlogit voluntary_exit copartisan                                            ///
                       health_age                                            /// 
					   polity2                                               ///
					   pre_politician                                        /// 
					   distcourt distcourt2                                  /// 
					   retirement_benefits second_term career_judge post_politician if polity2 > 4
est store M71

* Model 7.2
xtlogit voluntary_exit copartisan                                            ///
                       health_age co_age                            /// /* H1 */
					   polity2    co_polity                         /// /* H2 */
					   pre_politician                                        /// 
					   distcourt distcourt2                                  /// 
					   retirement_benefits second_term career_judge post_politician if polity2 > 4
est store M72

* Model 7.3
xtlogit voluntary_exit copartisan                                            ///
                       health_age co_age                            /// /* H1 */
					   polity2    co_polity                         /// /* H2 */
					   pre_politician co_politician                 /// /* H3 */
					   distcourt distcourt2                         /// /* H4 */
					   co_dist co_dist2                                     ///
					   retirement_benefits second_term career_judge post_politician if polity2 > 4
est store M73

* Model 7.4
xtlogit voluntary_exit copartisan                                            ///
                       health_age co_age                            /// /* H1 */
					   polity2    co_polity                         /// /* H2 */
					   age_polity co_age_polity               /// /* Optional */
					   pre_politician co_politician                 /// /* H3 */
					   distcourt distcourt2                         /// /* H4 */
					   co_dist co_dist2                                     ///
					   retirement_benefits second_term career_judge post_politician if polity2 > 4
est store M74

esttab M71 M72 M73 M74 using "Table7.rtf", cell(b(star fmt (%9.2f)) se(par)) ///
       stats(N chi2 ll, fmt(%9.0g %9.2f %9.2f) labels("N" "Chi^2" "Log-L") )starlevels(+ 0.1 * 0.05 ** 0.01) ///
       legend label varlabels(_cons Constant)title("Table 7. Models of Voluntary Retirement in Democracies, 1900-2004") mtitles replace
	   
	   
*** Figure for democracies (Model 7.4)
xtlogit voluntary_exit i.copartisan ///
                       c.health_age i.copartisan#c.health_age         /// /* H1 */
					   c.polity2    i.copartisan#c.polity2            /// /* H2 */
					   c.health_age#c.polity2 i.copartisan#c.health_age#c.polity2 /// 
					   i.pre_politician i.copartisan#i.pre_politician /// /* H3 */
					   c.distcourt c.distcourt#c.distcourt            /// /* H4 */
					   i.copartisan#c.distcourt i.copartisan#c.distcourt#c.distcourt ///
					   retirement_benefits second_term career_judge post_politician	if polity2 > 4	   

* H1 Age
margins copartisan, at (health_age = (30 (10) 90)) predict(pu0)
marginsplot, name("g01", replace) recast(line) recastci(rarea) ytitle("") title(3.1 - H1: Age) legend(region(lcolor(none)))
graph save g01 "g01.gph", replace

* H2 Party Competition
margins copartisan, at (health_age = (30 (10) 90) polity2 = 7) predict(pu0)
marginsplot, name("g02", replace) recast(line) recastci(rarea) ytitle("") title(3.2 - H2: Weak Democracy [+7]) legend(region(lcolor(none)))
graph save g02 "g02.gph", replace

margins copartisan, at (health_age = (30 (10) 90) polity2 = 10) predict(pu0)
marginsplot, name("g03", replace) recast(line) recastci(rarea) ytitle("") title(3.3 - H2: Full Democracy [+10]) legend(region(lcolor(none)))
graph save g03 "g03.gph", replace

* H3 Party ID
margins copartisan, at (health_age = (30 (10) 90) pre_politician = 0) predict(pu0)
marginsplot, name("g04", replace) recast(line) recastci(rarea) ytitle("") title(3.4 - H3: If Not Politician) legend(region(lcolor(none)))
graph save g04 "g04.gph", replace

margins copartisan, at (health_age = (30 (10) 90) pre_politician = 1) predict(pu0)
marginsplot, name("g05", replace) recast(line) recastci(rarea) ytitle("") title(3.5 - H3: If Prior Politician) legend(region(lcolor(none)))
graph save g05 "g05.gph", replace

* H4 Divided Court
margins copartisan, at (distcourt = (0 (.25) 1) health_age = 65) predict(pu0)
marginsplot, name("g06", replace) recast(line) recastci(rarea) ytitle("") title(3.6 - H4: Court Balance) xline(0.5) legend(region(lcolor(none)))
graph save g06 "g06.gph", replace

graph combine g01.gph g02.gph g03.gph g04.gph g05.gph g06.gph, ycommon

